import request from '@/router/axios';

// 查询商品表列表
export function getGoodsListData(query) {
  return request({
    url: '/items/manager/goods/list',
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
    params: query,
  });
}

// 查询商品表详细
export function getGoodsDetail(id) {
  return request({
    url: '/items/manager/goods/get/' + id,
    method: 'get',
  });
}

// 上架商品
export function upGoods(id) {
  return request({
    url: `/items/manager/goods/${id}/up`,
    method: 'put',
  });
}

//  下架商品
export function lowGoods(id, data) {
  return request({
    url: `/items/manager/goods/${id}/under`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'put',
    data: data,
  });
}

//  获取待审核商品分页列表
export function getAuthGoodsListData(params) {
  return request({
    url: '/items/manager/goods/auth/list',
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
    params: params,
  });
}
//  审核商品
export function authGoods(id, params) {
  return request({
    url: `/items/manager/goods/${id}/auth`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'put',
    data: params,
  });
}

//  获取商品规格分页列表
export function getSpecListData(params) {
  return request({
    url: '/items/manager/goods/spec',
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
    params: params,
  });
}

//  添加或修改规格设置
export function insertSpec(params) {
  return request({
    url: '/items/manager/goods/spec',
    contentType: 'application/x-www-form-urlencoded',
    method: 'post',
    data: params,
  });
}

//  添加或修改规格设置
export function updateSpec(id, params) {
  return request({
    url: `/items/manager/goods/spec/${id}`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'put',
    data: params,
  });
}

//删除gUI个
export function delSpec(id, params) {
  return request({
    url: `/items/manager/goods/spec/${id}`,
    method: 'delete',
    params: params,
  });
}

//  获取商品品牌分页列表
export function getManagerBrandPage(params) {
  return request({
    url: `/shop-core/brand/getByPage`,
    method: 'get',
    params: params,
  });
}

// 批量删除
export function delBrand(ids) {
  return request({
    url: `/shop-core/brand/delByIds/${ids}`,
    method: 'delete',
  });
}

//  添加
export function addBrand(params) {
  return request({
    url: '/shop-core/brand',
    method: 'post',
    data: params,
  });
}

// 修改品牌设置
export function updateBrand(params) {
  return request({
    url: `/shop-core/brand/${params.id}`,
    method: 'put',
    data: params,
  });
}

// 禁用品牌
export function disableBrand(id, params) {
  return request({
    url: `/shop-core/brand/disable/${id}`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'put',
    data: params,
  });
}

// 添加商品计量单位
export function addGoodsUnit(params) {
  return request({
    url: '/shop-core/goods/unit',
    method: 'post',
    data: params,
  });
}
// 分页获取商品计量单位
export function getGoodsUnitPage(params) {
  return request({
    url: `/shop-core/goods/unit/page`,
    method: 'get',
    params: params,
  });
}
// 编辑商品计量单位
export function updateGoodsUnit(params) {
  return request({
    url: `/shop-core/goods/unit`,
    method: 'put',
    data: params,
  });
}
// 删除商品计量单位
export function delGoodsUnit(ids) {
  return request({
    url: `/shop-core/goods/unit/${ids}`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'delete',
  });
}

//  获取商品sku分页列表
export function getGoodsSkuData(params) {
  return request({
    url: '/shop-core/goods/sku/list',
    method: 'get',
    params: params,
  });
}
// 获取商品es搜索分页类别
export function getGoodsEsData(params) {
  return request({
    // url: '/shop-core/goods/sku/list',
    url: '/shop-search/goods/es',
    method: 'get',
    params: params,
  });
}

// 设置热搜词
export function setHotWords(params) {
  return request({
    url: `/items/manager/hotwords`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'post',
    data: params,
  });
}

// 删除热搜词
export function deleteHotWords(words) {
  return request({
    url: `/items/manager/hotwords/${words}`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'delete',
  });
}

// 获取热搜词
export function getHotWords() {
  return request({
    url: `/items/manager/hotwords`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
  });
}

// 订单统计概览
export function getOrderOverView(params) {
  return request({
    url: `/statistics/manager/statistics/order/overview`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
    params: params,
  });
}

// 获取订单统计图表
export function getOrderChart(params) {
  return request({
    url: `/statistics/manager/statistics/order`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
    params: params,
  });
}

// 统计相关订单统计

export function statisticsOrderList(params) {
  return request({
    url: `/statistics/manager/statistics/order/order`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
    params: params,
  });
}

// 统计相关退单统计

export function statisticsOrderRefundList(params) {
  return request({
    url: `/statistics/manager/statistics/order/refund`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
    params: params,
  });
}

// 初始化商品索引
export function createIndex() {
  return request({
    url: `/items/manager/elasticsearch`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
  });
}

// 初始化商品索引
export function getProgress() {
  return request({
    url: `/items/manager/elasticsearch/progress`,
    contentType: 'application/x-www-form-urlencoded',
    method: 'get',
  });
}
